import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/double_control/get_user_by_id_entity.dart';
import 'package:get/get.dart';

class PeopleInformationDetailsController extends GetxController {
  /// 人员id
  String userId = Get.arguments as String;

  GetUserByIdEntity entity = GetUserByIdEntity();

  @override
  void onInit() {
    super.onInit();
    getDetailsData();
  }

  /// 获取详情数据
  void getDetailsData() async {
    // 获取详情
    final res = await HttpUtil().generateGetRequest<GetUserByIdEntity>(
      Interface.getEnterpriseUserById,
      queryParameters: {'userId': userId},
    ).execute();
    res.onSuccess((result) {
      if (result.data != null) {
        entity = result.data!;
        if (entity.certificateUrl!.isNotEmpty) {
          fileList.add(entity.certificateUrl!);
        }
        if (entity.documentUrl!.isNotEmpty) {
          fileList.add(entity.documentUrl!);
        }
      }
      update();
    });
  }

  /// 文件
  List<String> fileList = [];
}
